import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { renderRoutes } from 'react-router-config';

import store, { persistor } from './store/index';
import { PersistGate } from 'redux-persist/lib/integration/react';

import 'normalize.css';
import 'antd/dist/antd.css';
import './App.scss';
import './coverAntd.scss';

import routes from 'routes';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/lib/locale/zh_CN';
import moment from 'moment';
import 'moment/locale/zh-cn';

moment.locale('zh-cn');

import 'mock/index';

function App() {
  return (
    <ConfigProvider locale={zhCN}>
      <Provider store={store}>
        <PersistGate loading={null} persistor={persistor}>
          {/* 这个方法，每次有子路由时都需要使用，会传当前路由的子路由，可以说是按需加载，实时编译的，而不是一次性吧所有路由都渲染出来 */}
          <BrowserRouter>{renderRoutes(routes)}</BrowserRouter>
        </PersistGate>
      </Provider>
    </ConfigProvider>
  );
}

export default App;
